package exception;

public class Main1 {
//    public static void main(String[] args) throws Exception {
////        Integer.valueOf("ad");
//        try {
//            int[] array= {1,23,3};
//            System.out.println(array[4]);
//        }catch (Exception e) {
//            e.printStackTrace();
//            throw new Exception("sdflkdsf");
//        }
//        System.out.println("========");
//    }

    public static void main(String[] args){
        try {
            saveAge2(33);
        } catch (AgeIllegalException e) {
            throw new RuntimeException(e);
        }


        System.out.println("    =====      ");
    }
    public static void saveAge1(int age) {
        if(age > 0 && age < 150) {
            System.out.println("年龄成功保存: " + age);
        }else {
            throw new AgeIllegalRuntimeException("/age is illegal, your age is: " + age);
        }
    }

    public static void saveAge2(int age) throws AgeIllegalException {
        if(age > 0 && age < 150) {
            System.out.println("年龄成功保存: " + age);
        }else {
            throw new AgeIllegalException("/age is illegal, your age is: " + age);
        }
    }

}
